import {$get} from '../ajax/index'
import oils from '@/utils/油品.js'

// 门店列表
const shop_list = {
  name: 'shopList',
  ajax: async () => {
    let r = await $get('admin/shop/getShopByCompanyId')
    if (r.code == 200) {
      return r.obj
    } else {
      return []
    }
  }
}


// 礼品类型列表
const gift_type_list = {
  name: 'giftTypeList',
  ajax: async () => {
    let r = await $get('admin/shop/getCategoryByCompanyId')
    if (r.code == 200) {
      return r.obj
    } else {
      return []
    }
  }
}


// 会员类型列表
const member_type_list = {
  name: 'memberTypeList',
  ajax: async () => {
    let r = await $get('admin/member/getMemberTypeByCompanyId')
    if (r.code == 200) {
      const list = r.obj || []
      return list.sort((a, b) => a.minIntegral - b.minIntegral)
    } else {
      return []
    }
  }
}


// 油品列表
const oils_list = {
  name: 'oilsList',
  ajax: () => Array.from(oils.values())
}


// 专车列表
const car_type_list = {
  name: 'carTypeList',
  ajax: async () => {
    let r = await $get('admin/car/getCarTypeByCompanyId')
    if (r.code == 200) {
      return r.obj
    } else {
      return []
    }
  }
}
const ajaxs = [shop_list, member_type_list, gift_type_list, oils_list, car_type_list]

export default ajaxs
